//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package Move;

import Move.data;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.Timer;

public class GamePanel extends JPanel implements KeyListener, ActionListener {
    int[] peopleX = new int[100];
    int[] peopleY = new int[100];
    String fx = "right";
    Timer timer = new Timer(100, this);

    public GamePanel() {
        this.init();
        this.setFocusable(true);
        this.addKeyListener(this);
    }

    public void init() {
        this.peopleX[0] = 10;
        this.peopleY[0] = 310;
    }

    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        this.setBackground(Color.white);
        data.back.paintIcon(this, g, 10, 10);
        data.mouse.paintIcon(this, g, 300, 300);
        if (this.fx.equals("down")) {
            data.header.paintIcon(this, g, this.peopleX[0], this.peopleY[0]);
        } else if (this.fx.equals("right")) {
            data.right.paintIcon(this, g, this.peopleX[0], this.peopleY[0]);
        } else if (this.fx.equals("up")) {
            data.up.paintIcon(this, g, this.peopleX[0], this.peopleY[0]);
        } else if (this.fx.equals("left")) {
            data.left.paintIcon(this, g, this.peopleX[0], this.peopleY[0]);
        }

    }

    public void keyPressed(KeyEvent e) {
        int keyCode = e.getKeyCode();
        if (keyCode == 38) {
            this.fx = "up";
            this.peopleY[0] -= 25;
            this.repaint();
        } else if (keyCode == 40) {
            this.fx = "down";
            this.peopleY[0] += 25;
            this.repaint();
        } else if (keyCode == 37) {
            this.fx = "left";
            this.peopleX[0] -= 25;
            this.repaint();
        } else if (keyCode == 39) {
            this.fx = "right";
            this.peopleX[0] += 25;
            this.repaint();
        }

    }

    public void actionPerformed(ActionEvent e) {
    }

    public void keyReleased(KeyEvent e) {
    }

    public void keyTyped(KeyEvent e) {
    }
}
